<div class="container wx_wrap mini-innner">
    <div class="row">
        <div class="col-md-12 p0">
            <div class="wx_bar">
                <div class="wx_bar_back"><a id="indexBack" href="<?php echo $back_url?>"></a></div>
                <div class="wx_bar_tit">新增收货地址</div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-12">
            <div class="address_new"><!--这个页面有待修正-->
                <form id="address_form" method="post" action="/cart/address.html" onSubmit="return checkForm(this);">
                    <input type="hidden" id="adid" value="">
                    <p><label for="name"><span class="tit">收货人</span><input type="text" value="" name="consignee"   placeholder="姓名"></label></p>
                    <p><label for="mobile"><span class="tit">手机号码</span><input type="text"  name="mobile" ></label></p>
                    
                    <p style="height: 180px;">
                            <span class="tit">省市</span>
                            <span id="city"></span>
                    </p>
                    <p>
                        <label for="adinfo"><span class="tit">详细地址</span>
                        <input name="address" value="" type="text" placeholder="街道"></label>
                    </p>
                    <p><label for="adinfo"><span class="tit">邮政编码</span><input  name="zipcode" value="" maxlength="6" type="text" placeholder="邮政编码"></label></p>
                    <p class="action"><button  type="submit" id="buyBtn1" class="btn btn-warning btn-block mt10" >确认</button></p>
                </form>
            </div>
        </div>
    </div>
</div>

<script src="/misc/js/linkagesel.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $.getJSON('/public/district',$.proxy(function(json){
        XBW.linkagesel.data = json;
        delete(json);
        
        XBW.linkagesel.selector  = "#city";
        XBW.linkagesel.init(
                {
                    root:0,
                    district:'district',
                    selected:''
                }
        );
    }));
    
    $('#buyBtn2').click(function() {
       var address_id = $('#address_regionId').val();
       if(confirm('确认删除地址吗?'))
       {
        $.post('/personal/address/del.html',{address_id:address_id},function(ress){

        if(ress.status == 1)
        {
            window.location.href='/member/address/index.html';
        }

        },'json');
       }
    });
});
function checkForm(obj)
{
    if($("input[name='consignee']").val()==''){
        floatNotify.simple('收货人名字不能为空');
        return false;
    }
//     var region_id = $('#district').val();
//     if(region_id == ''){
//         floatNotify.simple('请选择省市');
//         return false;
//     }

    var mobile = $("input[name='mobile']").val();
    if(mobile==''){
        floatNotify.simple('手机号码不能为空');
        return false;
    }else{
        var reg = /^1[3|4|5|6|7|8|9][0-9]\d{4,8}$/;
        if(!reg.test(mobile))
        {
            floatNotify.simple('手机号码格式错误');
            return false;
        }
    }

//     if($("input[name='address']").val()==''){
//         floatNotify.simple('详细地址不能为空');
//         return false;
//     }
    
    showPageLoadingMsg('提交中...');
    $.post('/member/address/save.html',$(obj).serialize(),function(res){
        if(res.status != 1)
        {
            $(".ui-loader").remove();
            floatNotify.simple(res.msg);
            return false;
        }
        else
        {
            window.location.href='<?php echo $back_url;?>';
        }
    },'json');
    
    return false;
}

</script>